#include "libndpfs.h"
#include "dma.h"

//convert non-ndp path to ndp path to accelerate
//return 0 success, -1 already set, -2 set failed(permission), Positive numbers means dirfile block number
long set_ndp_path(char* path){
    //check is a file or dir
    struct stat sbuf;
    if(lstat(path,&sbuf)==-1)
        printf(stderr,"lstat error%s\n",path);
    // 判断是否是文件
    if((sbuf.st_mode & S_IFMT) == S_IFDIR)
    { 
        
    }

    //build .ndp file in this path
}

int open_ndp(const char * pathname, int flags, mode_t mode){
    return open(pathname, flags, mode);
}

ssize_t pread_ndp(int fd, void *buf, size_t count, off_t offset){
    return pread(fd, buf, count, offset);
}

ssize_t pwrite_ndp(int fd, const void *buf, size_t count, off_t offset){
    return pwrite(fd, buf, count, offset);
}

ssize_t ndp_by_fd(int fd, unsigned int operator){

}

ssize_t ndp_by_path(char* path, unsigned int operator){
    //1.先检查这个路径是否已经被转化为了ndp path
    //1.1先检查是目录还是文件，定位到所在目录
    

    //读取出

    //然后对这个路径下所有文件进行operator操作
}